<template>
	<view v-if="orderList[0].province != ''" @click="toAddressList">
		<view>
			{{ orderList[0].name + ' ' + orderList[0].tel }}
		</view>
		<view>
			{{ orderList[0].province + ' ' + orderList[0].city + orderList[0].county  + orderList[0].addressDetail }}
		</view>
	</view>
	<view v-else @click="toAddressList">
		请添加地址
	</view>
	<view class="cartList">
		<uni-swipe-action>
			<uni-swipe-action-item :threshold="0" :right-options="options1" @click="deleteItem(item.cartid)"
				v-for="item of orderList" :key="item.cartid">
				<view class="item">
					<view class="itemImage">
						<image :src="item.img1" mode=""></image>
					</view>
					<view class="itemInfo">

						<view class="proname">{{ item.proname }}</view>
						<view class="itemInfoOther">
							<view style="flex: 1">{{ item.originprice }}</view>
							<view style="min-width: 30px;">{{ item.num }}</view>
						</view>
					</view>
				</view>
			</uni-swipe-action-item>
		</uni-swipe-action>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { onLoad, onShow } from '@dcloudio/uni-app'
	import { getOrderListData } from '../../api/order';

	const orderList = ref([])
	const time = ref(0)
	const getList = (time) => {
		getOrderListData({
			userid: uni.getStorageSync('userid'),
			time: time
		}).then(res => {
			console.log(res.data.data)
			orderList.value = res.data.data
		})
	}

	onLoad((options) => {
		time.value = options.time
	})
	onShow(() => {
		getList(time.value)
	})
	const toAddressList = () => {
		uni.navigateTo({
			url: '/pages/addressList/addressList?time=' + time.value
		})
	}
</script>

<style>
	.cartList {}

	.cartList .item {
		display: flex;
	}

	.cartList .item .itemImage {
		width: 100px;
		height: 100px;
		-webkit-box-sizing: border-box;
		padding: 5px;
		display: flex;
	}

	.cartList .item .itemImage image {
		width: 90px;
		height: 90px;
	}

	.cartList .item .itemInfo {}

	.itemInfoOther {
		display: flex;
	}

	.proname {
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.numBtn {
		width: 30px;
		height: 30px;
	}

	.tip {
		width: 100%;
		height: 50px;
		background-color: #efefef;
		position: fixed;

		bottom: 0px;
		/* #ifdef H5*/
		bottom: 50px;
		/* #endif */
		display: flex;
	}
</style>